import React, {Component} from "react";
import {BoardContainer, BoardItemContainer} from "./style";
import {Col, Row} from "antd";
import {getHomeIndexColumns} from "@/api/sysHomeColumn";
import Config from "@/config";
import NoDataWindow from "@/common/window/NoDataWindow";

class BoardList extends Component {
    constructor(props) {
        super(props);
        this.state = {
            data: []
        }
    }

    componentDidMount() {
        getHomeIndexColumns().then(res => {
            this.setState({
                data: res.data
            })
        })
    }

    render() {
        const style = {
            display: 'block',
            width: '20px',
            height: 'auto',
            fontSize: '20px',
            float: 'left',
            marginRight: '5px',
            textAlign: 'left'
        }
        return (
            <BoardContainer>
                <Row gutter={[8, 0]}>
                    {
                        this.state.data ? this.state.data.map((item, index) => {
                            return (<Col span={24}
                                         key={item.id}
                                         onClick={() => item['linkPath'] ? window._ROUTER_.push(item['linkPath']) : null}>
                                    <BoardItemContainer>
                                        <Config.IconFont type={item['logoType']} style={style}/>
                                        <span>{item.title}</span>
                                    </BoardItemContainer>
                                </Col>
                            )
                        }) : <NoDataWindow/>
                    }
                </Row>
            </BoardContainer>
        )
    }
}

export default BoardList;
